#include <iostream>
using namespace std;
/*
11、Write a Number class that holds a double, and add overloaded operators for +, –, *, /, and assignment. Choose the return values for these functions so that expressions can be chained together, and for efficiency. Write an automatic type conversion operator intdouble( ).
*/

class Number{
public:
	double d;
	
	Number& operator+(const Number& n){
		Number temp;
		temp.d = this->d + n.d;
		return temp;
	}
	
	Number& operator-(const Number& n){
		Number temp;
		temp.d = this->d - n.d;
		
		return temp;
	}

	Number& operator*(const Number& n){
		Number temp;
		temp.d = this->d * n.d;
		
		return temp;
	}
	
	Number& operator/(const Number& n){
		Number temp;
		temp.d = this->d / n.d;
		
		return temp;
	}
	
	Number& operator=(const Number& n){
		Number temp;
		temp.d = n.d;
		
		return temp;
	}

	operator int(){
		return (int)d;
	}
	
};

int main(int argc, char *argv[]) {
	Number n1, n2, n3;
	n1.d = 3.14;
	n2.d = 6.14;
	n3.d = 2.14;
	
	// 测验
	Number result1 = n1 + n2;
	cout << result1.d << endl;
	
	Number result2 = n1 - n2;
	cout << result2.d << endl;

	Number result3 = n1 * n2;
	cout << result3.d << endl;
	
	Number result4 = n1 / n2;
	cout << result4.d << endl;
	
	Number result5 = n2;
	cout << result5.d << endl;

	cout << (int)result5 << endl;
}